<!DOCTYPE html>
<html lang="en">
    <head>
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
        <link rel="shortcut icon" href="/favicon.ico?">
        <meta charset="utf-8" />
        <title>{:lang('ADMIN_CENTER')}</title>

        <meta name="description" content="{:lang('ADMIN_CENTER')}" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />

        <!-- bootstrap & fontawesome -->
        <link rel="stylesheet" href="/static/admin/assets/css/bootstrap.min.css" />
        <link rel="stylesheet" href="/static/admin/assets/font-awesome/4.5.0/css/font-awesome.min.css" />

        <!-- page specific plugin styles -->

        <!-- text fonts -->
        <link rel="stylesheet" href="/static/admin/assets/css/fonts.googleapis.com.css" />

        <!-- ace styles -->
        <link rel="stylesheet" href="/static/admin/assets/css/ace.min.css" class="ace-main-stylesheet" id="main-ace-style" />



        <!--[if lte IE 9]>
            <link rel="stylesheet" href="/static/admin/assets/css/ace-part2.min.css" class="ace-main-stylesheet" />
        <![endif]-->
        <link rel="stylesheet" href="/static/admin/assets/css/ace-skins.min.css" />
        <link rel="stylesheet" href="/static/admin/assets/css/ace-rtl.min.css" />

        <!--[if lte IE 9]>
          <link rel="stylesheet" href="/static/admin/assets/css/ace-ie.min.css" />
        <![endif]-->

        <!-- inline styles related to this page -->

        <!-- ace settings handler -->
        <script src="/static/admin/assets/js/ace-extra.min.js"></script>

        <!-- HTML5shiv and Respond.js for IE8 to support HTML5 elements and media queries -->

        <!--[if lte IE 8]>
        <script src="/static/admin/assets/js/html5shiv.min.js"></script>
        <script src="/static/admin/assets/js/respond.min.js"></script>
        <![endif]-->
        <style type="text/css">
        /*.widget-header>.widget-title>input{width: 30%;line-height: 26px;}*/
        </style>
    </head>

    <body class="no-skin">
        <div id="navbar" class="navbar navbar-default ace-save-state">
            <div class="navbar-container ace-save-state" id="navbar-container">
                <button type="button" class="navbar-toggle menu-toggler pull-left" id="menu-toggler" data-target="#sidebar">
                    <span class="sr-only">Toggle sidebar</span>

                    <span class="icon-bar"></span>

                    <span class="icon-bar"></span>

                    <span class="icon-bar"></span>
                </button>

                <div class="navbar-header pull-left">
                    <a href="{:url('index/index')}" class="navbar-brand">
                        <small>
                            <i class="fa fa-server"></i>
                            {:lang('ADMIN_CENTER')}
                        </small>
                    </a>
                </div>

                <div class="navbar-buttons navbar-header pull-right" role="navigation">
                    <ul class="nav ace-nav">

                        <li class="light-blue dropdown-modal">
                            <a data-toggle="dropdown" href="#" class="dropdown-toggle">
                                <span class="user-info">
                                    <small>Welcome,</small>
                                    {:session('ADMIN_USERNAME')}
                                </span>

                                <i class="ace-icon fa fa-caret-down"></i>
                            </a>

                            <ul class="user-menu dropdown-menu-right dropdown-menu dropdown-yellow dropdown-caret dropdown-close">
                                <li>
                                    <a href="#my-changepass" role="button" data-toggle="modal">
                                        <i class="ace-icon fa fa-cog"></i>
                                        修改密码
                                    </a>
                                </li>

                                <li>
                                    <a href="{:url('login/logout')}">
                                        <i class="ace-icon fa fa-power-off"></i>
                                        退出登录
                                    </a>
                                </li>
                            </ul>
                        </li>
                    </ul>
                </div>

                <div id="my-changepass" class="modal fade" tabindex="-1">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                <h3 class="smaller lighter blue no-margin">修改密码</h3>
                            </div>

                            <div class="modal-body">
                                <div>
                                    <label for="account"> 原密码 </label>
                                    <input type="password" id="old_pwd" name="old_pwd" placeholder="请输入原密码" class="form-control">
                                </div>
                                <div class="hr hr-dotted hr-16"></div>
                                <div>
                                    <label for="account"> 新密码 </label>
                                    <input type="password" id="new_pwd" name="new_pwd" placeholder="请输入新密码" class="form-control">
                                </div>
                                <div class="hr hr-dotted hr-16"></div>
                                <div>
                                    <label for="account"> 重复新密码 </label>
                                    <input type="password" id="new_pwd2" name="new_pwd2" placeholder="请重复输入新密码" class="form-control">
                                </div>


                            </div>

                            <div class="modal-footer">
                                <button onclick="changepwd();" class="btn btn-success btn-block">保存</button>
                            </div>
                        </div><!-- /.modal-content -->
                    </div><!-- /.modal-dialog -->
                </div>

            </div><!-- /.navbar-container -->
        </div>

        <script type="text/javascript">
        function changepwd(){
            var old_pwd = $.trim($('#old_pwd').val());
            var new_pwd = $.trim($('#new_pwd').val());
            var new_pwd2 = $.trim($('#new_pwd2').val());
            if(old_pwd == ''){
                layer.tips('请输入原密码', '#old_pwd');
                return false;
            }
            if(new_pwd == ''){
                layer.tips('请输入新密码', '#new_pwd');
                return false;
            }
            if(new_pwd2 == ''){
                layer.tips('请重复新密码', '#new_pwd2');
                return false;
            }
            if(new_pwd != new_pwd2){
                layer.msg('请重复输入相同的密码');
                return false;
            }
            $.post( "{:url('admin/administrator_edit')}",{"old_pwd":old_pwd,"new_pwd":new_pwd}, function(data){
                // console.log(data)
                if(data.code) {
                    layer.msg('修改成功，请重新登录...',function(){
                        window.location.href="{:url('login/login')}";
                    });
                }else{
                    layer.msg(data.msg);
                }
            }, "json"); 

        }

        </script>
